<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>7-02 径向渐变</title>
</head>
<body>
  <canvas id="c" width="600" height="600" style="border: 1px solid #ccc;"></canvas>

  <script>
    const context = document.getElementById('c')
    const ctx = context.getContext('2d')

    const rgrd = ctx.createRadialGradient(60, 80, 0, 90, 80, 40)
    rgrd.addColorStop(0, 'pink')
    rgrd.addColorStop(0.5, 'yellow')
    rgrd.addColorStop(1, 'orange')

    ctx.arc(80, 80, 50, 0, Math.PI * 2, true)
    ctx.closePath()
    ctx.fillStyle = rgrd
    ctx.fill()
  </script>
</body>
</html>